let bookdata=uni.getStorageSync('shukudata')
let config=uni.getStorageSync('config')
console.log(config)
let _list = {
  getlist() {
	  console.log(' config.book_source_list', config.book_source_list)
    return new Promise(function(resolve, reject) {
      uni.request({
        url: config.book_source_list,
        success: function(re) {
         let data=re;
          // data.male.forEach(res => {
          //   res.bookCover[0] = unescape(res.bookCover[0]).replace('/agent/', '')
          // });
          // data.female.forEach(res => {
          //   res.bookCover[0] = unescape(res.bookCover[0]).replace('/agent/', '')
          // });
          resolve(re)
        }
      });

    });
  },
  gender(){
    return new Promise(function(resolve, reject) {
      uni.request({
        url: bookdata.shu_top,
        success: function(re) {
         let data=re.data;
          
          resolve(data)
        }
      });
    
    });
  },
  gendercat(id){
    return new Promise(function(resolve, reject) {
      uni.request({
        url: bookdata.shu_top_rend+ id, 
        success: function(re) {
         let data=re.data;
          resolve(data)
        }
      });
    
    });
  },
  categories(id,name,start,limit,finish,tag){
	  console.log(tag)
	  if(tag==='全部'){
		  tag=''
	  }
	  if(name==='全部'){
	  		  name=''
	  }
	  
	  
    return new Promise(function(resolve, reject) {
		 // #ifdef  MP
      uni.request({
        url: 'https://bookshelf.html5.qq.com/qbread/api/rank/list?ch=001995&groupid='+id+'&start='+start+'&count='+limit+'&sort=0&sub='+name+'&tag='+tag+'&words=3&finish='+finish+'&t=',
        success: function(re) {
			console.log(re)
         let data=re.data.rows;
          resolve(data)
        }
      });
	  // #endif 
	  
	  
    // #ifdef  APP-PLUS

   uni.request({
     url: config.wx_http_url, 
     data: {
		 url:'https://bookshelf.html5.qq.com/qbread/api/rank/list?ch=001995&groupid='+id+'&start='+start+'&count='+limit+'&sort=0&sub='+name+'&tag='+tag+'&words=3&finish='+finish+'&t='
	 },
     timeout: 6000,
     method:'POST',
     header: {
   	'content-type': 'application/json' //自定义请求头信息
	},
     sslVerify: false,
     success: (res) => {
		
       resolve(res.data.rows);
     }
   });
    // #endif 
    });
  }
}

export default _list;
